<?xml version="1.0" encoding="UTF-8"?>
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:h="http://java.sun.com/jsf/html"
	template="/resources/layout/templateInterno.xhtml"
	xmlns:a4j="http://richfaces.org/a4j"
	xmlns:t="http://myfaces.apache.org/tomahawk"
    xmlns:rich="http://richfaces.org/rich">
	<ui:define name="body">
	
	
	
<script>



</script>
	<div class="form">	
		<h:form  id="membroPesquisa" styleClass="form">
		<a4j:outputPanel ajaxRendered="true" id="pgMensagens" >
			  <div >
					<h:messages style="padding:5px" errorClass="errorMessage" infoClass="infoMessage"  />
			</div>
		</a4j:outputPanel>
		
		 <t:fieldset id="idfsDadosParametros" style="width:850px" legend="Filtros">
			<a4j:region>
			<div class="grid-3-12">
			<h:outputLabel  id="lbTipoPesquisa" class="form-lbl"  value="Aniversários:"/>
				<h:selectOneMenu id="cbTipoNiver" styleClass="form-txt"  value="#{membroRelatorioBean.tipoAniversario}">
					<f:selectItem itemLabel="Selecione..." itemValue=""/>
					<f:selectItem itemLabel="De Hoje" itemValue="H"/>
					<f:selectItem itemLabel="Do Dia" itemValue="D"/>
					<f:selectItem itemLabel="Do Mês" itemValue="M"/>
					<a4j:support ajaxSingle="true" event="onchange" action="#{membroRelatorioBean.pesqOpcoesTipoMembro}"  reRender="pgMes,pgDataPesquisa,idExibirPesquisar,idfsDadosParametros,cbOpcao,membroPesquisa">
					<f:setPropertyActionListener target="#{membroRelatorioBean.parametroPesquisa.dtPesquisa}" value="#{null}"/>
					 </a4j:support>
				</h:selectOneMenu>
			</div>
				<h:panelGroup id="pgMes" >
					<h:panelGroup  rendered="#{membroRelatorioBean.tipoAniversario == 'M'}">
					<div class="grid-3-12">
						<h:outputLabel  id="lbMes" class="form-lbl"  value="Mês:"/>
						<h:selectOneMenu id="cbMes" styleClass="form-txt"  value="#{membroRelatorioBean.mes}">
					 		<f:selectItems value="#{membroRelatorioBean.listaMes}" />
						</h:selectOneMenu>
						</div>
				</h:panelGroup>
			</h:panelGroup>
				<h:panelGroup id="pgDataPesquisa" >
					<h:panelGroup  rendered="#{membroRelatorioBean.tipoAniversario == 'D' and membroRelatorioBean.tipoAniversario != ''}">
						<div class="grid-3-12">
						<ui:define name="campoData">
							<h:outputLabel id="lbDataPesquisa" class="form-lbl" value="Data:" />
							 <rich:calendar id="clDataPesquisa" required="true" label="Data"
							 				firstWeekDay="0" 
							 				showWeeksBar="false"
							 				minDaysInFirstWeek="2" 
							 				value="#{membroRelatorioBean.parametroPesquisa.dtPesquisa}"
											datePattern="dd/MM/yyyy" inputSize="10" inputClass="maskDate" enableManualInput="true" disabled="false">
							</rich:calendar> 
							</ui:define>
							<rich:jQuery id="mskDataPesquisa" selector=".maskDate" timing="onload" query="mask('99/99/9999',{placeholder:' '})" />
						</div>
					</h:panelGroup>
				</h:panelGroup>
				
			<div class="grid-2-12">
					<h:outputLabel  id="lbTipoMembro" class="form-lbl"  value="Tipo:"/>
					<h:selectOneMenu id="cbTipoMembro" styleClass="form-txt" value="#{membroRelatorioBean.tipoMembro}">
				 		<f:selectItem itemLabel="Todos" itemValue="T"/>
				 		<f:selectItem itemLabel="Membro" itemValue="M"/>
				 		<f:selectItem itemLabel="Visitante" itemValue="V"/>
				 		<a4j:support ajaxSingle="true" event="onchange" action="#{membroRelatorioBean.pesqOpcoesTipoMembro}" reRender="idfsDadosParametros,cbOpcao,membroPesquisa"> </a4j:support>
			 		</h:selectOneMenu>
				</div>	
			<h:panelGroup id="pgIgrejaPertence" >
				<div class="grid-3-12">
					<h:outputLabel  id="lbLocalPertencePesquisa"  class="form-lbl"  value="Igreja:"/>
					<h:selectOneMenu  styleClass="form-txt" converter="indexConverter" id="cbLocalFrequenciaPesquisa"  value="#{membroRelatorioBean.igreja}">
					 		<f:selectItem itemLabel="Todas" itemValue=""/>
						   <t:selectItems value="#{membroRelatorioBean.listaIgreja}" var="igreja" itemLabel="#{igreja.nome}" itemValue="#{igreja}"/>
					</h:selectOneMenu>
				</div>
			</h:panelGroup>	
				
			</a4j:region>
			</t:fieldset>
			<div class="field-clear"></div>
					 <div class="grid-2-12">
						 <h:panelGroup  id="idExibirPesquisar">
							  <h:panelGroup  rendered="#{membroRelatorioBean.tipoAniversario != ''}">
										<a4j:commandButton id="cdbPesquisar" ajaxSingle="true" process="cbMes,cbLocalFrequenciaPesquisa,clDataPesquisa"
										styleClass="form-button" action="#{membroRelatorioBean.carregarAniversarios}" 
										reRender="pgResultadoPesquisa,pgResultados" value="Pesquisar" >
										</a4j:commandButton>
							</h:panelGroup>
							</h:panelGroup>
					</div>
				<div class="field-clear"></div>
			<h:panelGroup id="pgResultadoPesquisa">
				<h:panelGroup >
					<div style="padding: 10px" >
					 	<rich:dataTable rowClasses="odd, even" rows="10" 
					 	rendered="#{not empty membroRelatorioBean.listaMembrosVos}"
			                    		styleClass="dataTable rich-table rich-table-cell ui-widget-content ui-grid-content"
		                    			width="750" border="0" id="membroPesquisaTable"  var="membroVo" value="#{membroRelatorioBean.listaMembrosVos}" >
						  	<f:facet  name="header">
		                    <rich:columnGroup >
		                            <rich:column style="text-align: center; width:20px"  styleClass="ui-state-default" >
		                                <strong><h:outputText value="Matrícula" /></strong>
		                            </rich:column>
		                            <rich:column style="text-align: center;width:280px"  styleClass="ui-state-default" >
		                                <strong><h:outputText value="Nome" /></strong>
		                            </rich:column>
		                            <rich:column style="text-align: center;width:150px"  styleClass="ui-state-default" >
		                                <strong><h:outputText value="Igreja" /></strong>
		                            </rich:column>
		                            <rich:column style="text-align: center;width:160px"  styleClass="ui-state-default" >
		                                <strong><h:outputText value="Data" /></strong>
		                            </rich:column>
		                  </rich:columnGroup>
		                  </f:facet>
		 					<rich:columnGroup >	
		 					<rich:column style="text-align:center" >								
								<h:outputText rendered="#{membroVo.coSeqMembro != null}" value="#{membroVo.coSeqMembro}" />
								<h:outputText rendered="#{membroVo.coSeqMembro == null}" value="-" />
							</rich:column>		
							 <rich:column style="text-align:left">
								<h:outputText value="#{membroVo.nome}" />
							</rich:column>
							<rich:column style="text-align:left">
								<h:outputText value="#{membroVo.noIgrejaPertence}" />								
							</rich:column>
							<rich:column style="text-align:center">
								<h:outputText value="#{membroVo.dtNascimentoExtenso}" />
							</rich:column>
						</rich:columnGroup>
					</rich:dataTable>
					 <div class="field-clear"></div>
					<div class="grid-12-12">
						<rich:datascroller align="center" renderIfSinglePage="false" for="membroPesquisaTable" />
					</div>
				</div>
			
				 <div class="field-clear"></div>
				 
				  <a4j:region>
				  <h:panelGroup id="pgExibirBtImprimir">
					  <h:panelGroup rendered="#{membroRelatorioBean.exibirImprimir}" >
					   <div class="grid-2-12">
						<div style="padding-bottom: 20px;" >
							<a4j:commandLink id="cmdImprimir"  onclick="Richfaces.showModalPanel('panelImprimir');" process="cbTipoMembro"  reRender="pgExibirTipoRelatorio" immediate="true" styleClass="form-button"  value="Imprimir" >
							 		 <f:setPropertyActionListener target="#{membroRelatorioBean.listaResult}" value="#{membroRelatorioBean.listaMembrosVos}"/>
							 		  <f:setPropertyActionListener target="#{membroRelatorioBean.relatorioAniversario}" value="true"/>
							</a4j:commandLink>
						</div>
						</div>
						</h:panelGroup>
					</h:panelGroup>
				 </a4j:region>
			</h:panelGroup>
		</h:panelGroup>	
		 <div class="grid-5-12" >
			 <h:panelGroup  id="pgResultados">
				<h:panelGroup rendered="#{membroRelatorioBean.registroNaoEncontrado}" >
							<h:outputText styleClass="infoRegistroNaoEnc" value="#{msg['info.MGS_01']}"  />
				</h:panelGroup>
			</h:panelGroup>	
		</div>
	
	
	</h:form>	
	</div>
	<ui:include src="/views/cadastro/modalImprimir.xhtml" />
			
			<t:saveState value="#{membroRelatorioBean.relatorioAniversario}"/>
			<t:saveState value="#{membroRelatorioBean.exibirImprimir}"/>
			<t:saveState value="#{membroRelatorioBean.tipoMembro}"/>
			<t:saveState value="#{membroRelatorioBean.listaMes}"/>
			<t:saveState value="#{membroRelatorioBean.listaIgreja}"/>
			<t:saveState value="#{membroRelatorioBean.listaMembrosVos}"/>
			<t:saveState value="#{membroRelatorioBean.parametroPesquisa}"/>
			<t:saveState value="#{membroCadastro.membroPesquisa}"/>
			<t:saveState value="#{membroRelatorioBean.tipoAniversario}"/>
			<t:saveState value="#{membroRelatorioBean.listaMembrosSelecionados}"/>
	</ui:define>
</ui:composition>
